/*
Package make
@Author   : Uyynot
@Email    : uyynot@qq.com
@Time     : 2024/4/26 17:20
@File     : make_seeder.go
@Project  : gohub
@Desc     :
*/
package make

import (
	"fmt"
	"github.com/spf13/cobra"
)

var CmdMakeSeeder = &cobra.Command{
	Use:   "seeder",
	Short: "Create a new seeder file, example: make seeder user",
	Run:   runMakeSeeder,
	Args:  cobra.ExactArgs(1), // 1 argument is required
}

func runMakeSeeder(cmd *cobra.Command, args []string) {
	//格式化模型名称，返回一个model对象
	model := makeModelFormString(args[0])

	//拼接目标文件路径
	filePath := fmt.Sprintf("database/seeders/%s_seeder.go", model.TableName)

	//基于模板创建文件（做好变量替换）
	createFileFromStub(filePath, "seeder", model)
}
